# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=haskell-vector
pkgver=0.13.0.0
pkgrel=39
pkgdesc="Efficient Arrays"
url="https://hackage.haskell.org/package/vector"
license=("BSD")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-primitive' 'haskell-vector-stream')
makedepends=('ghc')
checkdepends=('haskell-base-orphans' 'haskell-hunit' 'haskell-quickcheck' 'haskell-random'
              'haskell-tasty' 'haskell-tasty-hunit' 'haskell-tasty-inspection-testing'
              'haskell-tasty-quickcheck')
source=("https://hackage.haskell.org/packages/archive/vector/${pkgver}/vector-${pkgver}.tar.gz")
sha512sums=('aadb33cb1acf3cc634631fbf6a8764fb92514a43c17395e305c9fcc91e0768ce51cec30c542a9ba998bf90e297732082ef5dbbf74232c885d613ac0fb7bcd2e1')

build() {
  cd vector-${pkgver}

  if (( CHECKFUNC )); then
      _opts=('--enable-tests')
  else
      _opts=('--disable-tests')
  fi

  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
      --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname "${_opts[@]}" \
      --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
  runhaskell Setup build $MAKEFLAGS
  runhaskell Setup register --gen-script
  runhaskell Setup unregister --gen-script
  sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd vector-$pkgver
  runhaskell Setup test --show-details=direct
}

package() {
  cd vector-${pkgver}
  install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
  install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
  runhaskell Setup copy --destdir="$pkgdir"
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/${pkgname}/LICENSE
  rm -f "$pkgdir"/usr/share/doc/${pkgname}/LICENSE
}
